import unittest
from api.ihrm_emp_add_delete_update_select import TestIhrmADUS
from common.assert_ulit import assert_ulit
from common.db_util import DButil
from common.get_header import get_header
from config import TEL




class TestEmpAdd(unittest.TestCase):
    header = None,

    @classmethod
    def setUpClass(cls) -> None:
        cls.header = get_header()

    def setUp(self) -> None:
        # 删除手机号  (格式化)
        delete_sql = f"delete from bs_user where mobile = '{TEL}'"
        DButil.uid_db(delete_sql)

    def tearDown(self) -> None:
        # 删除手机号  (格式化)
        delete_sql = f"delete from bs_user where mobile = '{TEL}'"
        DButil.uid_db(delete_sql)

    # 添加员工
    def test01_add_emp(self):
        # 准备数据
        json_data = {"username": "业务猪018", "mobile": TEL, "workNumber": "9527"}
        res = TestIhrmADUS.add_tmp(self.header, json_data)
        print("添加-必选", res.json())
        # 断言
        assert_ulit(self, res, 200, True, 10000, '操作成功！')

        # self.assertEqual(200,res.status_code)
        # self.assertEqual(True,res.json().get("success"))
        # self.assertEqual(10000, res.json().get("code"))
        # self.assertIn('操作成功！', res.json().get("message"))

    # 组合参数
    def test02_add_emp(self):
        json_data = {"username": "业务猪018", "mobile": TEL, "workNumber": "9527", "formfoEMP": "2"}
        res = TestIhrmADUS.add_tmp(self.header, json_data)
        print("添加-组合", res.json())
        # 断言
        assert_ulit(self, res, 200, True, 10000, '操作成功！')

    # 全部参数
    def test03_add_emp(self):
        # 准备数据
        json_data = {
            "username": "大猪乔治",
            "mobile": TEL,
            "timeOfEntry": "2021-12-01",
            "formOfEmployment": 1,
            "workNumber": "777888",
            "departmentName": "测试",
            "departmentId": "1452603344685203456",
            "correctionTime": "2021-12-30T16:00:00.000Z"
        }
        res = TestIhrmADUS.add_tmp(self.header, json_data)
        print("全部参数", res.json())
        # 断言
        assert_ulit(self, res, 200, True, 10000, '操作成功！')
